package gui;

import manager.Manager;

public class GuiThread extends Thread
{
    //How long to wait for each update
    long interval;
    //Whether or not to continue running
    boolean cont;
    //Reference back to main window
    MainWindow win;
    //Reference back to Manager
    Manager mgr;

    public GuiThread(MainWindow mw, Manager m)
    {
        win = mw;
        mgr = m;
        interval = 1000;
    }

    /**
     * While the program is running, call getGuiData in mgr passing
     * MainWindow’s visibleX and visibleY. Calls updateUI in 
     * MainWindow passing array returned from getGuiData
     */
    public void run()
    {
        cont = true;
        while (cont)
        {
            win.updateUI(mgr.getGuiData(win.visibleX, win.visibleY));
            try
            {
                sleep(interval);
            }
            catch(InterruptedException e)
            {
                //What's to do?
            }
        }
    }

    //Sets cont to false
    void halt()
    {
        cont = false;
    }


}
